﻿@model PagedList<YiYiTong.Rocket.Model.Manager.UserModel>
@{
    ViewBag.Title = "选择用户";
    Layout = "~/Views/Shared/_Layout.cshtml";

    ManagerQueryModel paramModel = new ManagerQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (ManagerQueryModel)ViewBag.paramModel;
    }
    Dictionary<string, string> dc = new Dictionary<string, string>();
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
}

<p>
    用户列表（请点击账户名选择）&nbsp; &nbsp; &nbsp;
    <button type="submit" id="btnClose" class="btn btn-primary">关闭</button>
</p>

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("selectmanageruser", "Common")" method="get">
    <p>
        显示
        @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        条记录&nbsp;&nbsp;
        
        用户角色：
        <select id="RoleID" name="RoleID" style="width:150px;">
            <option value="-10" @(paramModel.RoleID == -10 ? "selected" : "")>全部角色</option>
            @{
                var ds = RoleBiz.Instance.GetPageList("", "", 1, 1000);
                IList<YiYiTong.Rocket.Model.Manager.RoleModel> rolelist = new ModelHandler<YiYiTong.Rocket.Model.Manager.RoleModel>().FillModel(ds, 1);
                foreach (var item in rolelist)
                {
                    dc.Add(item.roleId.ToString(), item.roleName);
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.RoleID.ToString());
            }
        </select>
        搜索：
        <input type="text" name="UserName" id="UserName" class="abc input-default" placeholder="" value="@paramModel.UserName">&nbsp;<button type="submit" class="btn btn-primary">查询</button>
    </p>

</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <td>姓名</td>
            <td>手机号</td>
            <td>角色</td>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        foreach (var m in Model)
        {
            <tr>
                <td style="width:20%"><input name="checkbox" type="radio" value="@m.uid&@m.realName" />@(m.realName)</td>
                <td style="width:20%">@m.mobile</td>
                <td style="width:20%">@m.RoleIds</td>
            </tr>
        }
        <tr><td colspan="3"><button type="submit" id="btnOK" class="btn btn-primary">确定</button></td></tr>
        
    }
</table>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    BUI.use(['bui/form', 'bui/overlay'], function (Form, overlay) {
        new Form.Form({
            srcNode: '#S_Form'
        }).render();
    });
    var UserMobile = "";
    var RealName = "";
    var UID = "";
    var arr = new Array();
    $(function () {
        $('#btnOK').on('click', function () {
            //遍历当前页checked值
            $("input[name='checkbox']").each(function () {
                if (this.checked == true && $(this).val() != "on" && $(this).val() != "") {
                    arr = $(this).val().split('&');
                    UID = arr[0];
                    RealName = arr[1];
                }
            });

            if (UID != "") {
                window.opener.getNewLinkValue(RealName, UID);
                window.close();
            }
            else {
                alert("请选择用户");
            }

        });

        $('#btnClose').bind('click', function () {
            window.close();
            window.opener.closediv();
        });
    });

    $(window).unload(function (evt) {
        window.opener.closediv();
    });
</script>